import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;
import java.util.concurrent.atomic.AtomicInteger;

public class Test28 {
      public class TreeNode {
        int val = 0;
        TreeNode left = null;
        TreeNode right = null;
        public TreeNode(int val) {
          this.val = val;
        }
      }
    public int maxPathSum (TreeNode root) {
        if (root.left == null && root.right == null) {
            return root.val;
        }
        int left = Integer.MIN_VALUE;
        int right = Integer.MIN_VALUE;
        if (root.left != null)
            left = maxPathSum(root.left);
        if (root.right != null)
            right = maxPathSum(root.right);

        if (root.val < 0) {
            if(left<0 && right<0){
                return Math.max(Math.max(left,right),root.val);
            }
            return left > right ? left : right;
        } else {
            if (right > 0 && left > 0) {
                return left + right + root.val;
            } else {
                return left > right ? left + root.val : right + root.val;
            }
        }

    }




    public static void main02(String[] args) {
        Scanner in = new Scanner(System.in);
        int n = in.nextInt();
        int[] a=new int[n+1];

        Map<Integer,Integer> hash=new HashMap<>();

        for(int i=1;i<=n;i++) {
            a[i] = in.nextInt();
            if (a[i] == i) {
                hash.put(i, 0);
            } else {
                hash.put(i, a[i]);
            }
        }

        int count=0;
        for(int i=1;i<=n;i++){

                if (hash.get(i) == 0) count++;
            }

        if(count == 1){
            System.out.println(count);
        }else{
            int sum=1;
            count-=1;
            while(count-- !=0){
                sum*=(n-1);
                n++;
            }
            System.out.println(sum);
        }
    }



    public static void main01(String[] args) {
        Scanner in = new Scanner(System.in);
        int q = in.nextInt();

        while (q-- != 0) {
            int x = in.nextInt();
            if (x % 2 == 0) {
                System.out.println(x);
            } else {
                StringBuffer st=new StringBuffer();
                st.append(x);
                StringBuffer s=new StringBuffer();
                int tmp=x;
                int count=0;
                while(tmp!=0){
                    if((tmp%10)%2 == 0){
                        count++;
                        break;
                    }
                    s.append(tmp%10);
                    st.deleteCharAt(st.length()-1);
                    tmp/=10;
                    count++;
                }


                if(tmp == 0){
                    System.out.println("-1");
                }else{
                    s.reverse();
                    st.insert(st.length()-1,s);
                    System.out.println(st);
                }
            }
        }
    }
}
